<template>
	<view class="zone">
		<Header title="开箱记录" headertype="1" color="#fff"></Header>
		<view class="main">
			<view class="list">
				<view class="item" v-for="(item , index) in list" :key="index">
					<p>{{item.explain}} <text>{{item.create_time}}</text> </p>
					<scroll-view scroll-x class="sclist">
						<view class="sc_box">
							<view class="sc_item" v-for="(v,i) in item.equip1" :key="i">
								<view class="imgbox">
									<image :src="imgurl + v.img" mode="widthFix" />
								</view>
								<text v-if="v.id ==1">{{v.num}}{{v.name}}</text>
								<text v-else>{{v.name}}</text>
							</view>
						</view>
					</scroll-view>
				</view>
				<view v-if="list.length==0" class="zanwu">
					<image src="http://img.cpgm.cc/panda/static/duoBao/baiwu.png" class="zaneu_img" mode="widthFix">
					</image>
					<view class="">
						没有数据哦~
					</view>
				</view>
				<u-loadmore v-else :status="status" :icon-type="iconType" :load-text="loadText" />
			</view>
			
		</view>
	</view>
</template>

<script>
import config from '@/common/config/index.js'
	export default {
		data() {
			return {
				page:1,
				max_page:'',
				status: 'loadmore',
				iconType: 'flower',
				loadText: {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '没有更多了'
				},
				list:'',
				imgurl: config.imgurl,
			};
		},
		onLoad(){
			this.openLogs();
		},
		onReachBottom() {
			if (this.page >= this.max_page){
				this.status = 'nomore' 
				return;
			} 
			this.status = 'loading';
			this.page = ++this.page;
			this.openLogs()
			setTimeout(() => {
				if (this.page > this.max_page || this.page == this.max_page) this.status = 'nomore';
				else this.status = 'loading';
			}, 500)
		},
		methods: {
			async openLogs(){
				let res = await this.$http.index.openLogs({
					page:this.page,
				});
				this.list = [...this.list , ...res.data];
				this.max_page = res.page 
				if (this.page > this.max_page || this.page == this.max_page) this.status = 'nomore';
			},
		},
	}
</script>

<style lang="less">
.zone {
	background: linear-gradient(180deg, #00684B 0%, rgba(0,106,74,0) 30%) #171A1F;
	background-size: 100% 100%;
	min-height: 100vh;
}

.main {
	padding: 10px;
}

.item {
	padding: 10px;
	background: rgba(0, 103, 75, 0.51);
	border-radius: 7px;
	margin: 5px 0;

	p {
		color: #fff;
		font-size: 14px;
		font-weight: 600;

		text {
			font-size: 12px;
			font-weight: normal;
			margin-left: 2px;
		}
	}
}


.sclist {
	width: 100%;
	margin-top: 10px;
}

.sc_box {
	display: flex;
	align-items: center;
}

.sc_item {
	display: flex;
	align-items: center;
	flex-direction: column;
	margin-right: 10px;

	.imgbox {
		background: linear-gradient(180deg, #FFED67 0%, #FFF494 100%);
		border-radius: 7px;
		border: 2px solid #fff;
		padding: 0 3px;

		image {
			width: 65px;
		}
	}

	text {
		color: #000000;
		font-size: 12px;
		margin-top: 4px;
	}
}

.zanwu {
		font-size: 14px;
		color: #A1A1A1;
		font-weight: 500;
		margin-top: 50%;
		text-align: center;

		.zaneu_img {
			width: 70%;

		}
	}

</style>
